<template>
  <el-dialog title="新增数据" v-bind="$attrs" v-on="$listeners" @close="onClose" width="30%">
    <el-form ref="newForm" :model="formData" label-width="80px">
      <el-form-item label="日期">
        <el-input v-model="formData.date" placeholder="请输入日期"></el-input>
      </el-form-item>
      <el-form-item label="姓名">
        <el-input v-model="formData.name" placeholder="请输入姓名"></el-input>
      </el-form-item>
      <el-form-item label="地址">
        <el-input v-model="formData.address" placeholder="请输入地址"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="close">取消</el-button>
      <el-button type="primary" @click="handelConfirm">确定</el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  props: {
    newDialogVisible: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      formData: {
        date: '',
        name: '',
        address: ''
      }
    };
  },
  methods: {
    //关闭对话框
    onClose() {

    },
    //取消对话框
    close() {
      this.$emit('update:visible', false);
    },
    //处理确认新增数据的操作
    handelConfirm() {
      const newData = {
        date: this.formData.date,
        name: this.formData.name,
        address: this.formData.address
      };
      this.$emit('addData', newData); // 发送新增数据事件给父组件
    }
  }
};
</script>

<style scoped>
/* 根据需要添加样式 */
</style>